/**
 * @Author:Geln Yang
 * @Created:2008-7-30
 * $ Revision: 1.0 $
 * $ Author: Geln Yang $
 * $ Date: 2008-7-30 $
 */
package com.hgy.commonsale.core.webwork.validator;

import com.opensymphony.xwork.validator.ValidationException;
import com.opensymphony.xwork.validator.validators.FieldValidatorSupport;

/**
 * @Author:Geln Yang
 * @Created:2008-7-30
 */
public class PasswordValidator extends FieldValidatorSupport {

	public void validate(Object object) throws ValidationException {
		String fieldName = getFieldName();
		String val = (String) getFieldValue(fieldName, object);
		if (val == null || val.trim().equals("") || val.matches("[\\d]+") || val.matches("[a-zA-Z]+")) {
			addFieldError(fieldName, object);
		} else {
			char[] list = val.toCharArray();
			char temp = list[0];
			for (int i = 1; i < list.length; i++) {
				if (temp == list[i]) {
					addFieldError(fieldName, object);
					break;
				}
				temp = list[i];
			}
		}

	}

}
